#define DEBUG
#include <cstdio>
#define INF 0x7fffffffffffff
#define MAXK 9
#define MAXN (1<<MAXK)

using namespace std;

long long min(long long a, long long b) {
  return a<b ? a : b;
}

int main() {
#ifdef DEBUG
  freopen("3166.in", "r", stdin);
  freopen("3166.out", "w", stdout);
#endif

  static int w[MAXN+1][MAXN+1];
  int k;
  scanf("%d", &k);
  for (int i=0; i<(1<<k); i++) {
    for (int j=0; j<(1<<k); j++) {
      scanf("%d", &w[i][j]);
    }
  }

  static long long f[MAXN+1][MAXN+1];
  for (int i=0; i<=(1<<k); i++) {
    for (int j=0; j<=(1<<k); j++) {
      f[i][j] = INF;
    }
  }
  for (int i=0; i<(1<<k); i++) {
    f[0][i] = 0;
  }
  for (int i=0; i<(1<<k)-1; i++) {
    int lowbit=(i+1)&(-(i+1));
    for (int j=0; j<(1<<k); j++) {
      if (f[i][j]<INF) {
	int s=(j^lowbit)&~(lowbit-1), t=s+lowbit-1;
	for (int l=s; l<=t; l++) {
	  f[i+1][l] = min(f[i+1][l], f[i][j]+w[j][l]);
	}
      }
    }
  }

  long long ans=INF;
  for (int i=0; i<(1<<k); i++) {
    ans = min(ans, f[(1<<k)-1][i]);
  }
  printf("%lld", ans);

  fcloseall();
  return 0;
}
